package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemHomeServiceTrademarkBinding;
import com.sgb.kjwl.model.entity.enterprise.IntellpropEntity;
import com.sgb.kjwl.utils.PointUtils;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class HomeTrademarkAdapter extends BaseRecycleAdapter<IntellpropEntity> {


    public HomeTrademarkAdapter(Context context, List<IntellpropEntity> datas) {
        super(context, R.layout.item_home_service_trademark, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, IntellpropEntity intellpropEntity) {
        ItemHomeServiceTrademarkBinding binding = (ItemHomeServiceTrademarkBinding) holder.getmBinding();
        binding.setViewModel(intellpropEntity);
        TextView tv_tag = holder.getItem().findViewById(R.id.tv_item_intel_prop_publish);
        switch (intellpropEntity.getPublishType()) {
            case 0://个人
                tv_tag.setText("个人");
                tv_tag.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                break;
            case 1://企业
                tv_tag.setText("企业");
                tv_tag.setBackgroundResource(R.drawable.shape_radius_1_solid_bule);
                break;
            case 2://团队
                tv_tag.setText("团队");
                tv_tag.setBackgroundResource(R.drawable.ractangle_radius_1_solid_yellow);
                break;
            default:
                tv_tag.setVisibility(View.GONE);
                break;
        }
        if (intellpropEntity.getLabel() != null && intellpropEntity.getLabel().contains("1")) {
            holder.setVisible(R.id.tv_item_intel_prop_hot, true);
        } else {
            holder.setVisible(R.id.tv_item_intel_prop_hot, false);
        }
        if (intellpropEntity.getLabel() != null && intellpropEntity.getLabel().contains("2")) {
            holder.setVisible(R.id.tv_item_intel_prop_urgent_sale, true);
        } else {
            holder.setVisible(R.id.tv_item_intel_prop_urgent_sale, false);
        }
        binding.price.setText(intellpropEntity.getPrice() != -1 ? "¥" + PointUtils.price(intellpropEntity.getPrice()) : "议价");
    }
}
